
package JET.physics.bodies;

import JET.geom.Vec2d;

/**
 *
 * @author 057Ry
 */
public class RigidBodyHelper {

    public static int getRigidBodyVertexIndexClosestToVec(RigidBody rb, Vec2d v)
    {
        double minDist = Double.MAX_VALUE;
        int index = -1;
        for(int i=0; i<rb.dynVecList.size(); i++) {
            double dist = rb.dynVecList.get(i).getPosition().getSubbed(v).getMagnitudeSquared();
            if (dist<minDist) {
                index = i;
                minDist = dist;
            }
        }

        return index;
    }

}
